package servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import pojo.User;
import service.UserManager;
import service.factory.UserManagerFactory;

/**
 * 在登录注册的时候验证用户是否已注册
 *
 */
public class ValidateServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
    private UserManager manager;
    
    public ValidateServlet() {
        super();
        manager = UserManagerFactory.getInstance();
    }

 
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String name = request.getParameter("name");
		
		User user = manager.loadUserByName(name);
		
		if(user == null){
			response.getWriter().write("true");
		} else {
			response.getWriter().write("false");
		}
	}
 
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		 
	}

}
